/*
 * COPYRIGHT. HSBC HOLDINGS PLC 2016. ALL RIGHTS RESERVED.
 * 
 * This software is only to be used for the purpose for which it has been
 * provided. No part of it is to be reproduced, disassembled, transmitted,
 * stored in a retrieval system nor translated in any human or computer
 * language in any way or for any other purposes whatsoever without the
 * written consent of HSBC Holdings plc.
 */
package com.pactera.integral.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.EntityListeners;
import javax.persistence.MappedSuperclass;

import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

@MappedSuperclass
@EntityListeners(AuditingEntityListener.class)
public class CommonEntity implements Serializable {
    /**
     * @field serialVersionUID
     */
    private static final long serialVersionUID = 1L;
    /**
     * @field createdBy
     */
    @CreatedBy
    @Column(name = "CREATED_BY", length = 32)
    private String createdBy;
    /**
     * @field createdTime
     */
    @CreatedDate
    @Column(name = "CREATED_TIME")
    private Date createdTime;
    /**
     * @field lastUpdatedBy
     */
    @LastModifiedBy
    @Column(name = "LAST_UPDATED_BY", length = 32)
    private String lastUpdatedBy;
    /**
     * @field lastUpdatedTime
     */
    @LastModifiedDate
    @Column(name = "LAST_UPDATED_TIME")
    private Date lastUpdatedTime;

    /**
     * @return createdBy.
     */
    public String getCreatedBy() {
        return createdBy;
    }

    /**
     * @param createdby created by.
     */
    public void setCreatedBy(final String createdby) {
        this.createdBy = createdby;
    }

    /**
     * @return createdTime.
     */
    public Date getCreatedTime() {
        Date newDate = null;
        if (createdTime != null) {
            newDate = new Date(createdTime.getTime());
        }
        return newDate;
    }

    /**
     * @param createdtime created time.
     */
    public void setCreatedTime(final Date createdtime) {
        if (createdtime != null) {
            this.createdTime = new Date(createdtime.getTime());
        }
    }

    /**
     * @return lastUpdatedBy.
     */
    public String getLastUpdatedBy() {
        return lastUpdatedBy;
    }

    /**
     * @param lastupdatedby last updated by.
     */
    public void setLastUpdatedBy(final String lastupdatedby) {
        this.lastUpdatedBy = lastupdatedby;
    }

    /**
     * @return lastUpdatedTime.
     */
    public Date getLastUpdatedTime() {
        Date newDate = null;
        if (lastUpdatedTime != null) {
            newDate = new Date(lastUpdatedTime.getTime());
        }
        return newDate;
    }

    /**
     * @param lastupdatedtime last updated time.
     */
    public void setLastUpdatedTime(final Date lastupdatedtime) {
        if (lastupdatedtime != null) {
            this.lastUpdatedTime = new Date(lastupdatedtime.getTime());
        }
    }

}
